<?php
// +----------------------------------------------------------------------
// | CoreThink [ Simple Efficient Excellent ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014 http://www.corethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: jry <598821125@qq.com> <http://www.corethink.cn>
// +----------------------------------------------------------------------
namespace Admin\Controller;
use Think\Controller;
/**
 * 后台用户控制器
 * @author jry <598821125@qq.com>
 */
class DescriptionsController extends AdminController{
		
	public function index(){
		 //搜索
//      $keyword = I('keyword', '', 'string');
//      $condition = array('like','%'.$keyword.'%');
//      $map['project_number|project_name'] = array($condition, $condition,'_multi'=>true);

        //获取所有用户
        $map['tablename']='descriptions';
       $map['status'] = array('egt', '0'); //禁用和正常状态
        $data_list = D('Descriptions')->page(!empty($_GET["p"])?$_GET["p"]:1, C('ADMIN_PAGE_ROWS'))->where($map)->order('id desc')->select();
        $page = new \Common\Util\Page(D('Descriptions')->where($map)->count(), C('ADMIN_PAGE_ROWS'));

 
        $attr['title'] = '新增分类';
        $attr['class'] = 'btn btn-primary';
        $attr['href']  = U('Admin/Descriptions/add');
		
        foreach ($data_list as $list){
            $but['title']=$list['title'];
            $but['class']='btn btn-primaryy';
            $but['href'] = U('Admin/Descriptions/showclass',array('tablename'=>$list['fieldname'],'fieldname'=>$list['fieldvalue']));
            $arr_but[]=$but;
        }
		
		
        //使用Builder快速建立列表页面。
        $builder = new \Common\Builder\ListBuilder();
        $builder->setMetaTitle('数据字典列表') //设置页面标题
            ->addTopButton('self',$attr)
			->addTopButton('delete')
			->addTopButton('selfs',$arr_but)
			
			
	 //    ->setSearch('请输入项目编号/项目名称', U('index'))
			->addTableColumn('id', 'ID')
			->addTableColumn('title', '字段标题')
			->addTableColumn('identification', '标识')
			->addTableColumn('tablename', '所属表名')
			->addTableColumn('fieldname','字段名')
			->addTableColumn('fieldvalue','字段值')
			->addTableColumn('parentfieldid','父字段ID')
		//  ->addTableColumn('status', '状态', 'status')
			->addTableColumn('right_button', '操作', 'btn')
			->setTableDataList($data_list) //数据列表
			->setTableDataPage($page->show()) //数据列表分页
			->addRightButton('edit')   //添加编辑按钮
		 
			->addRightButton('delete') //添加删除按钮
			->display();
			}

			
		
	 public function edit($id){
        //获取信息
        $info = D('Descriptions')->find($id);

        if(IS_POST){
            $customer_object = D('Descriptions');
            $customer_object->create();
            if($customer_object->save()){
                $this->success('更新成功', U('index'));
            }else{
                print_r($customer_object);
                $this->error('更新失败', $customer_object->getError());
            }
        }else{
            $info = D('Descriptions')->find($id);
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('编辑') //设置页面标题
                    ->setPostUrl(U('edit')) //设置表单提交地址
                      ->addFormItem('id', 'hidden', 'ID', 'ID')
                  ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
                    ->setFormData($info)
                    ->display();
        }
    }	
/////客户级别
		public function customer_level(){
		$map['tablename']=I('customer_level');	
	    $map['status'] = array('egt', '0'); //禁用和正常状态
	    
        $data_list = D('Descriptions')->page(!empty($_GET["p"])?$_GET["p"]:1, C('ADMIN_PAGE_ROWS'))->where($map)->order('id desc')->select();
        $page = new \Common\Util\Page(D('Descriptions')->where($map)->count(), C('ADMIN_PAGE_ROWS'));
		
		
		$attr['title'] = '新增';
        $attr['class'] = 'btn btn-primary';
        $attr['href']  = U('Admin/Descriptions/customer_level_add');
		
		$attrl['title'] = '当前【 客户级别 】';
        $attrl['class'] = 'btn btn-primaryyy';
        $attrl['href']  = U('Admin/Descriptions/customer_level',array('customer_level'=>'customer_level'));
		
		$attrs['title'] = '客户来源';
        $attrs['class'] = 'btn btn-primaryy';
        $attrs['href']  = U('Admin/Descriptions/customer_source',array('customer_source'=>'customer_source'));

        $attrst['title'] = '服务类型';
        $attrst['class'] = 'btn btn-primaryy';
        $attrst['href']  = U('Admin/Descriptions/service_type',array('service_type'=>'service_type'));
		
		$attrt['title'] = '任务类型';
        $attrt['class'] = 'btn btn-primaryy';
        $attrt['href']  = U('Admin/Descriptions/task_type',array('task_type'=>'task_type'));
		
		 $attrtj['title'] = '紧急类型';
        $attrtj['class'] = 'btn btn-primaryy';
        $attrtj['href']  = U('Admin/Descriptions/emergency_level',array('emergency_level'=>'emergency_level'));
		
		 $at['title'] = '编辑';
        $at['class'] = 'label label-primary';
        $at['href']  = U('Admin/Descriptions/customer_level_edit', array('id' => '__data_id__'));

        //使用Builder快速建立列表页面。
        $builder = new \Common\Builder\ListBuilder();
        $builder->setMetaTitle('数据字典列表') //设置页面标题
        ->addTopButton('self',$attrl)
            ->addTopButton('self',$attr)
			->addTopButton('delete')
			
			->addTopButton('self',$attrs)
			->addTopButton('self',$attrst)
			->addTopButton('self',$attrt)
			->addTopButton('self',$attrtj)
	 //    ->setSearch('请输入项目编号/项目名称', U('index'))
			->addTableColumn('id', 'ID')
			->addTableColumn('title', '字段标题')
			->addTableColumn('identification', '标识')
			->addTableColumn('tablename', '所属表名')
			->addTableColumn('fieldname','字段名')
			->addTableColumn('fieldvalue','字段值')
			->addTableColumn('parentfieldid','父字段ID')
		//  ->addTableColumn('status', '状态', 'status')
			->addTableColumn('right_button', '操作', 'btn')
			->setTableDataList($data_list) //数据列表
			->setTableDataPage($page->show()) //数据列表分页
			->addRightButton('self',$at)   //添加编辑按钮
		 
			->addRightButton('delete') //添加删除按钮
			->display();
			}
		
		public function customer_level_add(){
			if(IS_POST){
			$customer_object = D(
		'Descriptions');
		
            $data = $customer_object->create();
            if($data){
                $id = $customer_object->add();
                if($id){
                    $this->success('新增成功', U('customer_level',array('customer_level'=>'customer_level')));
                }else{
                    $this->error('新增失败');
                }
            }else{
                $this->error($customer_object->getError());
            }
        }else{
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('新增客户') //设置页面标题
                    ->setPostUrl(U('customer_level_add')) //设置表单提交地址
               
                    ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
					 
                    ->setFormData(array('tablename' =>'customer_level','fieldname'=>'customer_level')) //注册方式为后台添加
                    ->display();
        }
		}
		
		public function customer_level_edit($id){
			 $info = D('Descriptions')->find($id);

        if(IS_POST){
            $customer_object = D('Descriptions');
             
            if($customer_object->save($_POST)){
                $this->success('更新成功', U('Admin/Descriptions/customer_level',array('customer_level'=>'customer_level')));
            }else{
                $this->error('更新失败', $customer_object->getError());
            }
        }else{
            $info = D('Descriptions')->find($id);
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('编辑') //设置页面标题
                    ->setPostUrl(U('customer_level_edit')) //设置表单提交地址
                      ->addFormItem('id', 'hidden', 'ID', 'ID')
                  ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
                    ->setFormData($info)
                    ->display();
        }
			
		}
	////////////客户	来源
	public function customer_source(){
		$map['tablename']=I('customer_source');	
	    $map['status'] = array('egt', '0'); //禁用和正常状态
	    
        $data_list = D('Descriptions')->page(!empty($_GET["p"])?$_GET["p"]:1, C('ADMIN_PAGE_ROWS'))->where($map)->order('id desc')->select();
        $page = new \Common\Util\Page(D('Descriptions')->where($map)->count(), C('ADMIN_PAGE_ROWS'));
		
		
		$attr['title'] = '新增';
        $attr['class'] = 'btn btn-primary';
        $attr['href']  = U('Admin/Descriptions/customer_source_add');
		
		$attrl['title'] = '客户级别';
        $attrl['class'] = 'btn btn-primaryy';
        $attrl['href']  = U('Admin/Descriptions/customer_level',array('customer_level'=>'customer_level'));
		
		$attrs['title'] = '当前【 客户来源 】';
        $attrs['class'] = 'btn btn-primaryyy';
        $attrs['href']  = U('Admin/Descriptions/customer_source',array('customer_source'=>'customer_source'));

        $attrst['title'] = '服务类型';
        $attrst['class'] = 'btn btn-primaryy';
        $attrst['href']  = U('Admin/Descriptions/service_type',array('service_type'=>'service_type'));
		
		$attrt['title'] = '任务类型';
        $attrt['class'] = 'btn btn-primaryy';
        $attrt['href']  = U('Admin/Descriptions/task_type',array('task_type'=>'task_type'));
		
		 $attrtj['title'] = '紧急类型';
        $attrtj['class'] = 'btn btn-primaryy';
        $attrtj['href']  = U('Admin/Descriptions/emergency_level',array('emergency_level'=>'emergency_level'));
		
		 $at['title'] = '编辑';
        $at['class'] = 'label label-primary';
        $at['href']  = U('Admin/Descriptions/customer_source_edit', array('id' => '__data_id__'));

        //使用Builder快速建立列表页面。
        $builder = new \Common\Builder\ListBuilder();
        $builder->setMetaTitle('数据字典列表') //设置页面标题
           ->addTopButton('self',$attrs)
            ->addTopButton('self',$attr)
			->addTopButton('delete')
			->addTopButton('self',$attrl)
			
			->addTopButton('self',$attrst)
			->addTopButton('self',$attrt)
			->addTopButton('self',$attrtj)
	 //    ->setSearch('请输入项目编号/项目名称', U('index'))
			->addTableColumn('id', 'ID')
			->addTableColumn('title', '字段标题')
			->addTableColumn('identification', '标识')
			->addTableColumn('tablename', '所属表名')
			->addTableColumn('fieldname','字段名')
			->addTableColumn('fieldvalue','字段值')
			->addTableColumn('parentfieldid','父字段ID')
		//  ->addTableColumn('status', '状态', 'status')
			->addTableColumn('right_button', '操作', 'btn')
			->setTableDataList($data_list) //数据列表
			->setTableDataPage($page->show()) //数据列表分页
			->addRightButton('self',$at)   //添加编辑按钮
		 
			->addRightButton('delete') //添加删除按钮
			->display();
			}
		
		public function customer_source_add(){
			if(IS_POST){
			$customer_object = D(
		'Descriptions');
		
            $data = $customer_object->create();
            if($data){
                $id = $customer_object->add();
                if($id){
                    $this->success('新增成功', U('customer_source',array('customer_source'=>'customer_source')));
                }else{
                    $this->error('新增失败');
                }
            }else{
                $this->error($customer_object->getError());
            }
        }else{
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('新增客户') //设置页面标题
                    ->setPostUrl(U('customer_source_add')) //设置表单提交地址
               
                    ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
					 
                    ->setFormData(array('tablename' =>'customer_source','fieldname'=>'customer_source')) //注册方式为后台添加
                    ->display();
        }
		}
		
		public function customer_source_edit($id){
			 $info = D('Descriptions')->find($id);

        if(IS_POST){
            $customer_object = D('Descriptions');
             
            if($customer_object->save($_POST)){
                $this->success('更新成功', U('Admin/Descriptions/customer_source',array('customer_source'=>'customer_source')));
            }else{
                $this->error('更新失败', $customer_object->getError());
            }
        }else{
            $info = D('Descriptions')->find($id);
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('编辑') //设置页面标题
                    ->setPostUrl(U('customer_source_edit')) //设置表单提交地址
                      ->addFormItem('id', 'hidden', 'ID', 'ID')
                  ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
                    ->setFormData($info)
                    ->display();
        }
			
		}
	///////////服务类型
	public function showclass($tablename,$fieldname){
		$map['tablename']=$tablename;
		$map['filedname']=$fieldname;
	    $map['status'] = array('egt', '0'); //禁用和正常状态
	    
        $data_list = D('Descriptions')->page(!empty($_GET["p"])?$_GET["p"]:1, C('ADMIN_PAGE_ROWS'))->where($map)->order('id desc')->select();
        $page = new \Common\Util\Page(D('Descriptions')->where($map)->count(), C('ADMIN_PAGE_ROWS'));
		
		
	      $attr['title'] = '新增';
        $attr['class'] = 'btn btn-primary';
        $attr['href']  = U('Admin/Descriptions/add',array('tablename'=>$tablename,'fieldname'=>$fieldname));
        
        $map['tablename']='descriptions';
        $map['status'] = array('egt', '0'); //禁用和正常状态
        $data_list2 = D('Descriptions')->where($map)->order('id desc')->select();
	foreach ($data_list2 as $list){
            $but['title']=$list['title'];
            $but['class']='btn btn-primaryy';
            $but['href'] = U('Admin/Descriptions/showclass',array('tablename'=>$list['fieldname'],'fieldname'=>$list['fieldvalue']));
            $arr_but[]=$but;
        }
		
		 $at['title'] = '编辑';
        $at['class'] = 'label label-primary';
        $at['href']  = U('Admin/Descriptions/edit', array('id' => '__data_id__'));

        //使用Builder快速建立列表页面。
        $builder = new \Common\Builder\ListBuilder();
        $builder->setMetaTitle('数据字典列表') //设置页面标题
          
            ->addTopButton('self',$attr)
			->addTopButton('delete')
			->addTopButton('selfs',$arr_but)
		
	 //    ->setSearch('请输入项目编号/项目名称', U('index'))
			->addTableColumn('id', 'ID')
			->addTableColumn('title', '字段标题')
			->addTableColumn('identification', '标识')
			->addTableColumn('tablename', '所属表名')
			->addTableColumn('fieldname','字段名')
			->addTableColumn('fieldvalue','字段值')
			->addTableColumn('parentfieldid','父字段ID')
		//  ->addTableColumn('status', '状态', 'status')
			->addTableColumn('right_button', '操作', 'btn')
			->setTableDataList($data_list) //数据列表
			->setTableDataPage($page->show()) //数据列表分页
			->addRightButton('self',$at)   //添加编辑按钮
		 
			->addRightButton('delete') //添加删除按钮
			->display();
			}
		
		public function add($tablename='',$fieldname=''){
			if(empty($tablename)){
				$tablename="descriptions";
			}
			if(IS_POST){
			$customer_object = D('Descriptions');
            $data = $customer_object->create();
            if($data){
                $id = $customer_object->add();
                if($id){
                    $this->success('新增成功', U('showclass',array('tablename'=>$tablename,'fieldname'=>$fieldname)));
                }else{
                    $this->error('新增失败');
                }
            }else{
                $this->error($customer_object->getError());
            }
        }else{
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('新增客户') //设置页面标题
                    ->setPostUrl(U('add')) //设置表单提交地址
               
                    ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
					 
                    ->setFormData(array('tablename' =>$tablename,'fieldname'=>$fieldname)) //注册方式为后台添加
                    ->display();
        }
		}
		
		public function service_type_edit($id){
			 $info = D('Descriptions')->find($id);

        if(IS_POST){
            $customer_object = D('Descriptions');
             
            if($customer_object->save($_POST)){
                $this->success('更新成功', U('Admin/Descriptions/service_type',array('service_type'=>'service_type')));
            }else{
                $this->error('更新失败', $customer_object->getError());
            }
        }else{
            $info = D('Descriptions')->find($id);
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('编辑') //设置页面标题
                    ->setPostUrl(U('service_type_edit')) //设置表单提交地址
                      ->addFormItem('id', 'hidden', 'ID', 'ID')
                  ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
                    ->setFormData($info)
                    ->display();
        }
			
		}
	//////////任务类型
	
	public function task_type(){
		$map['tablename']=I('task_type');	
	    $map['status'] = array('egt', '0'); //禁用和正常状态
	    
        $data_list = D('Descriptions')->page(!empty($_GET["p"])?$_GET["p"]:1, C('ADMIN_PAGE_ROWS'))->where($map)->order('id desc')->select();
        $page = new \Common\Util\Page(D('Descriptions')->where($map)->count(), C('ADMIN_PAGE_ROWS'));
		
		
		$attr['title'] = '新增';
        $attr['class'] = 'btn btn-primary';
        $attr['href']  = U('Admin/Descriptions/task_type_add');
		
		$attrl['title'] = '客户级别';
        $attrl['class'] = 'btn btn-primaryy';
        $attrl['href']  = U('Admin/Descriptions/customer_level',array('customer_level'=>'customer_level'));
		
		$attrs['title'] = '客户来源';
        $attrs['class'] = 'btn btn-primaryy';
        $attrs['href']  = U('Admin/Descriptions/customer_source',array('customer_source'=>'customer_source'));

        $attrst['title'] = '服务类型';
        $attrst['class'] = 'btn btn-primaryy';
        $attrst['href']  = U('Admin/Descriptions/service_type',array('service_type'=>'service_type'));
		
		$attrt['title'] = '当前【 任务类型 】';
        $attrt['class'] = 'btn btn-primaryyy';
        $attrt['href']  = U('Admin/Descriptions/task_type',array('task_type'=>'task_type'));
		
		 $attrtj['title'] = '紧急类型';
        $attrtj['class'] = 'btn btn-primaryy';
        $attrtj['href']  = U('Admin/Descriptions/emergency_level',array('emergency_level'=>'emergency_level'));
		
		 $at['title'] = '编辑';
        $at['class'] = 'label label-primary';
        $at['href']  = U('Admin/Descriptions/task_type_edit', array('id' => '__data_id__'));

        //使用Builder快速建立列表页面。
        $builder = new \Common\Builder\ListBuilder();
        $builder->setMetaTitle('数据字典列表') //设置页面标题
          
           ->addTopButton('self',$attrt)
            ->addTopButton('self',$attr)
			->addTopButton('delete')
			->addTopButton('self',$attrl)
			->addTopButton('self',$attrs)
			 ->addTopButton('self',$attrst)
			->addTopButton('self',$attrtj)
			
	 //    ->setSearch('请输入项目编号/项目名称', U('index'))
			->addTableColumn('id', 'ID')
			->addTableColumn('title', '字段标题')
			->addTableColumn('identification', '标识')
			->addTableColumn('tablename', '所属表名')
			->addTableColumn('fieldname','字段名')
			->addTableColumn('fieldvalue','字段值')
			->addTableColumn('parentfieldid','父字段ID')
		//  ->addTableColumn('status', '状态', 'status')
			->addTableColumn('right_button', '操作', 'btn')
			->setTableDataList($data_list) //数据列表
			->setTableDataPage($page->show()) //数据列表分页
			->addRightButton('self',$at)   //添加编辑按钮
		 
			->addRightButton('delete') //添加删除按钮
			->display();
			}
		
		public function task_type_add(){
			if(IS_POST){
			$customer_object = D(
		'Descriptions');
		
            $data = $customer_object->create();
            if($data){
                $id = $customer_object->add();
                if($id){
                    $this->success('新增成功', U('task_type',array('task_type'=>'task_type')));
                }else{
                    $this->error('新增失败');
                }
            }else{
                $this->error($customer_object->getError());
            }
        }else{
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('新增客户') //设置页面标题
                    ->setPostUrl(U('task_type_add')) //设置表单提交地址
               
                    ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
					 
                    ->setFormData(array('tablename' =>'task_type','fieldname'=>'task_type')) //注册方式为后台添加
                    ->display();
        }
		}
		
		public function task_type_edit($id){
			 $info = D('Descriptions')->find($id);

        if(IS_POST){
            $customer_object = D('Descriptions');
             
            if($customer_object->save($_POST)){
                $this->success('更新成功', U('Admin/Descriptions/task_type',array('task_type'=>'task_type')));
            }else{
                $this->error('更新失败', $customer_object->getError());
            }
        }else{
            $info = D('Descriptions')->find($id);
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('编辑') //设置页面标题
                    ->setPostUrl(U('task_type_edit')) //设置表单提交地址
                      ->addFormItem('id', 'hidden', 'ID', 'ID')
                  ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
                    ->setFormData($info)
                    ->display();
        }
			
		}
	
	//////////紧急类型
	
	public function emergency_level(){
		$map['tablename']=I('emergency_level');	
	    $map['status'] = array('egt', '0'); //禁用和正常状态
	    
        $data_list = D('Descriptions')->page(!empty($_GET["p"])?$_GET["p"]:1, C('ADMIN_PAGE_ROWS'))->where($map)->order('id desc')->select();
        $page = new \Common\Util\Page(D('Descriptions')->where($map)->count(), C('ADMIN_PAGE_ROWS'));
		
		
		$attr['title'] = '新增';
        $attr['class'] = 'btn btn-primary';
        $attr['href']  = U('Admin/Descriptions/emergency_level_add');
		
		$attrl['title'] = '客户级别';
        $attrl['class'] = 'btn btn-primaryy';
        $attrl['href']  = U('Admin/Descriptions/customer_level',array('customer_level'=>'customer_level'));
		
		$attrs['title'] = '客户来源';
        $attrs['class'] = 'btn btn-primaryy';
        $attrs['href']  = U('Admin/Descriptions/customer_source',array('customer_source'=>'customer_source'));

        $attrst['title'] = '服务类型';
        $attrst['class'] = 'btn btn-primaryy';
        $attrst['href']  = U('Admin/Descriptions/service_type',array('service_type'=>'service_type'));
		
		$attrt['title'] = '任务类型';
        $attrt['class'] = 'btn btn-primaryy';
        $attrt['href']  = U('Admin/Descriptions/task_type',array('task_type'=>'task_type'));
		
		 $attrtj['title'] = '当前【 紧急类型 】';
        $attrtj['class'] = 'btn btn-primaryyy';
        $attrtj['href']  = U('Admin/Descriptions/emergency_level',array('emergency_level'=>'emergency_level'));
		
		 $at['title'] = '编辑';
        $at['class'] = 'label label-primary';
        $at['href']  = U('Admin/Descriptions/emergency_level_edit', array('id' => '__data_id__'));

        //使用Builder快速建立列表页面。
        $builder = new \Common\Builder\ListBuilder();
        $builder->setMetaTitle('数据字典列表') //设置页面标题
          ->addTopButton('self',$attrtj)
          
            ->addTopButton('self',$attr)
			->addTopButton('delete')
			->addTopButton('self',$attrl)
			->addTopButton('self',$attrs)
			->addTopButton('self',$attrst)
			->addTopButton('self',$attrt)
			
	 //    ->setSearch('请输入项目编号/项目名称', U('index'))
			->addTableColumn('id', 'ID')
			->addTableColumn('title', '字段标题')
			->addTableColumn('identification', '标识')
			->addTableColumn('tablename', '所属表名')
			->addTableColumn('fieldname','字段名')
			->addTableColumn('fieldvalue','字段值')
			->addTableColumn('parentfieldid','父字段ID')
		//  ->addTableColumn('status', '状态', 'status')
			->addTableColumn('right_button', '操作', 'btn')
			->setTableDataList($data_list) //数据列表
			->setTableDataPage($page->show()) //数据列表分页
			->addRightButton('self',$at)   //添加编辑按钮
		 
			->addRightButton('delete') //添加删除按钮
			->display();
			}
		
		public function emergency_level_add(){
			if(IS_POST){
			$customer_object = D(
		'Descriptions');
		
            $data = $customer_object->create();
            if($data){
                $id = $customer_object->add();
                if($id){
                    $this->success('新增成功', U('emergency_level',array('emergency_level'=>'emergency_level')));
                }else{
                    $this->error('新增失败');
                }
            }else{
                $this->error($customer_object->getError());
            }
        }else{
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('新增客户') //设置页面标题
                    ->setPostUrl(U('emergency_level_add')) //设置表单提交地址
               
                    ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
					 
                    ->setFormData(array('tablename' =>'emergency_level','fieldname'=>'emergency_level')) //注册方式为后台添加
                    ->display();
        }
		}
		
		public function emergency_level_edit($id){
			 $info = D('Descriptions')->find($id);

        if(IS_POST){
            $customer_object = D('Descriptions');
             
            if($customer_object->save($_POST)){
                $this->success('更新成功', U('Admin/Descriptions/emergency_level',array('emergency_level'=>'emergency_level')));
            }else{
                $this->error('更新失败', $customer_object->getError());
            }
        }else{
            $info = D('Descriptions')->find($id);
            //使用FormBuilder快速建立表单页面。
            $builder = new \Common\Builder\FormBuilder();
            $builder->setMetaTitle('编辑') //设置页面标题
                    ->setPostUrl(U('emergency_level_edit')) //设置表单提交地址
                      ->addFormItem('id', 'hidden', 'ID', 'ID')
                  ->addFormItem('title','text', '字段标题', '字段标题')
		            ->addFormItem('identification','text', '标识', '标识')
		            ->addFormItem('tablename','text', '所属表名', '所属表名')
					->addFormItem('fieldname','text','字段名','字段名')
					->addFormItem('fieldvalue','text','字段值','字段值')
					->addFormItem('parentfieldid','text','父字段ID','父字段ID')
                    ->setFormData($info)
                    ->display();
        }
			
		}
	
	
	
	
	
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
}
	